<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>客户资金表 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="capFund_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">
        <div class="fieldBox col_33">
            <div class="label">来款户名</div>
            <div class="field">
                <input name="comeName" id="comeName" type="text" class="ui-textbox" value="${capFundVO.comeName}"
                       validate="{required:true,maxlength:64}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">来款账号</div>
            <div class="field">
                <input name="comeCode" id="comeCode" type="text" class="ui-textbox" value="${capFundVO.comeCode}"
                       validate="{required:false,number:true,maxlength:21}">
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">来款金额</div>
            <div class="field">
                <input name="amount" id="amount" type="text" class="ui-textbox" value="" onchange="Num(this)" validate="{required:true,number:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">收款账户</div>
            <div class="field">
                <input name="acceptName" id="acceptName" type="text" class="ui-textbox" value="${capFundVO.acceptName}"
                       validate="{required:true,maxlength:64}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">收款账号</div>
            <div class="field">
                <input name="acceptCode" id="acceptCode" type="text" class="ui-textbox" value="${capFundVO.acceptCode}"
                       validate="{required:true,maxlength:64}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">交易(到账)日期</div>
            <div class="field">
                <input name="acceptDate" id="acceptDate" type="text" class="ui-datepicker" value="${capFundVO.acceptDates}" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">实际到账日期</div>
            <div class="field">
                <input name="acceptActualDate" id="acceptActualDate" type="text" class="ui-datepicker" value="${capFundVO.acceptActualDates}" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>

        <div class="fieldBox col_33">
            <div class="label">事业部</div>
            <div class="field">
                <input name="fundBelongOrgCd" id="fundBelongOrgCd" data-value="${capFundVO.fundBelongOrgCd}"
                       validate="{required:true}" placeholder="请选择" ltype="combobox">
                <span class="requiredSymbol">*</span>
            </div>
        </div>

        <div class="fieldBox col_33">
            <div class="label">是否自动划扣</div>
            <div class="field">
                <select name="isAutoCharge" id="isAutoCharge" >
                    <option value="0" <c:if test="${capFundVO.isAutoCharge == 0}">selected="selected"</c:if>>否</option>
                    <option value="1" <c:if test="${capFundVO.isAutoCharge == 1}">selected="selected"</c:if>>是</option>
                </select>
            </div>
        </div>

        <div class="fieldBox col_100">
            <div class="label">摘要</div>
            <div class="field">
                <textarea name="docketRem" id="docketRem" class="ui-textarea l-textarea" value="${capFundVO.docketRem}"
                          rows="4" cols="120" style="width: 99%;" validate="{required:false,maxlength:2000}">${capFundVO.docketRem}</textarea>
                <input type="text" id="fundInputCd" name="fundInputCd" value="1" style="display:none;">
                <input type="text" id="version" name="version" value="${capFundVO.version}" style="display:none;">
            </div>
        </div>
    </div>
    <div class="btnsBox">
        <span id="saveCapFund_Btn" class="sq-button sq-button-round l-dialog-btn-ok">保存</span>
        <span id="closeBtn" class="sq-button sq-button-round co_normal">关闭</span>
        <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
    </div>
</form>
<script>
    $(function () {
        var capFundId = "${capFundVO.id}";//主键ID
        var permissions='${permissions}';
        var amount='${capFundVO.amount}';
        if(amount){
            $("#amount").val(parseFloat('${capFundVO.amount}')/100);
        }

        //事业部
        $("#fundBelongOrgCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#capFund_form").ligerForm({
            validate: true
        });
        liger.get("fundBelongOrgCd").setData(${fundBelongOrgCdList});

        var accDialog=null;
        $("#acceptName").focus(function(event) {
            accDialog=$.ligerDialog.SQopen({
                url: "<%=path%>/system/sysBkAccInfo/toChooseListPage.do",
                width: 800,
                height: 400,
                title: "选择收款账户"
            });
        });
        if (permissions == "0") {
			liger.get("acceptDate").setDisabled(false);
        }
        /*保存*/
        $("#saveCapFund_Btn").click(function (event) {
            var form = liger.get("capFund_form");
            if (!form.valid()) {
                top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            //data["amount"]=parseFloat($("#amount").val()*100);
            $.ligerDialog.hide();
            var _url;
            if (capFundId == '') {//新增
                _url = '<%=path%>/capital/capFund/add.do';
            } else {//修改
                _url = '<%=path%>/capital/capFund/modify.do?id=' + capFundId;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: _url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#clearBtn").click();
                        parent.$("#searchBtn").click();
                        frameElement.dialog.close();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });

        /*关闭*/
        $("#closeBtn").click(function (event) {
            frameElement.dialog.close();
        });
    });

    //允许输入数字和小数点
    function Num(obj){
        obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
    }
</script>
</body>
</html>
